/*
 * CreateSimpleProductControler.java
 *
 * Created on 8 janvier 2008, 17:24
 */
package com.reimscopie.controlers ;

import com.reimscopie.* ;
import com.reimscopie.beans.interfaces.* ;


/**
 * This web controler create a new product.
 */
public class CreateSimpleProductControler extends WebControler {
  
  // the admin bean
  private ReimsCopieAdminRemote bean ;
  
  
  
  /**
   * Create a new instance of <code>CreateSimpleProductControler</code>.
   */
  public CreateSimpleProductControler() throws Exception {
    
    String name ="com.reimscopie.beans.session.ReimsCopieAdminBean_" +
        ReimsCopieAdminRemote.class.getName()+"@Remote" ;
    
    bean = (ReimsCopieAdminRemote)getContext().lookup(name) ;
    
  }
  
  // name
  private String name ;
  public void    setName(String name  )      {this.name = name;}
  public String  getName()                   {return name;}
  
  // description
  private String desc ;
  public void    setDescription(String desc) {this.desc = desc;}
  public String  getDescription()            {return desc;}
  
  // picture
  private String picture ;
  public void    setPicture(String picture)  {this.picture = picture;}
  public String getPicture()                 {return picture;}
  
  // price
  private float   price ;
  public void    setPrice(float price)       {this.price = price;}
  public float   getPrice()                  {return price;}
  
  // stock
  private int     stock ;
  public void    setStock(int stock)         {this.stock = stock;}
  public int     getStock()                  {return stock;}
  
  
  /**
   * Create a new simple product.
   */
  public void create() throws Exception {
    
    beginTransaction() ;
    
    SimpleProduct product = new SimpleProduct(name,desc,picture,true,price,stock) ;
    bean.createSimpleProduct(product) ;
    
    commitTransaction() ;
    
  }
  
}
